package com.xiezc.entity;

import lombok.Data;

import java.util.Date;

/**
 * Created by Administrator on 2017/5/19.
 */
@Data
public class FileInfo {


    private Integer id;
    /**
     * 文件所属用户id
     */
    private int userId;
    /**
     * 文件名不包含文件的路径
     */
    private String fileName;

    /**
     * 文件的路径, 相对于同步文件夹的根路径
     */
    private String filePath;
    /**
     * 文件的大小
     */
    private long fileLength;
    /**
     * 文件的MD5码
     */
    private String fileMd5;
    /**
     * 文件的最后修改时间
     */
    private Date updateTime;

    /**
     * 数据库中这条记录的创建时间
     */
    private Date createTime;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        if (!super.equals(o)) return false;

        FileInfo fileInfo = (FileInfo) o;

        if (!fileName.equals(fileInfo.fileName)) return false;
        if (!filePath.equals(fileInfo.filePath)) return false;
        return fileMd5.equals(fileInfo.fileMd5);
    }

    @Override
    public int hashCode() {
        int result = super.hashCode();
        result = 31 * result + fileName.hashCode();
        result = 31 * result + filePath.hashCode();
        result = 31 * result + fileMd5.hashCode();
        return result;
    }

    @Override
    public String toString() {
        return "FileInfo{" +
                "id=" + id +
                ", userId=" + userId +
                ", fileName='" + fileName + '\'' +
                ", filePath='" + filePath + '\'' +
                ", fileLength=" + fileLength +
                ", fileMd5='" + fileMd5 + '\'' +
                ", updateTime=" + updateTime +
                ", createTime=" + createTime +
                '}';
    }
}
